use "$edited/final_data", clear
keep if date==22500 & population<=10000 & gps<=10 & gps>0

capture eststo clear
capture estimates clear

replace sh_antivax_gps = sh_antivax_gps * 100
lab var sh_antivax_gps "Share vaccine-skeptic GPs (in \%)"


local munchars "sh_dose_1_20211214 sh_dose_2_20211214 sh_dose_3_20211214 gps sh_antivax_gps near_vaccination_center mun_pop sh_pop_female sh_pop_0_14 sh_pop_15_29 sh_pop_30_44 sh_pop_45_59 sh_pop_60_74 sh_pop_75_99 sh_pop_pflichtschule sh_pop_mededu sh_pop_matura sh_pop_uni sh_pop_foreign salaries pensions near_waldorf sh_fpo sh_brunner sh_cases_pre cum_deaths_27dec2020"


quietly forvalues i=0/1 {
	count if any_antivax_gps==`i'
	local n`i' = r(N)
}

*note: if error here, run: ssc install estout, replace in the command console
estpost sum `munchars' if any_antivax_gps==0
matrix mean1 = e(mean), J(1,1,`n0')
matrix sd1 = e(sd), J(1,1,.)

estpost sum `munchars' if any_antivax_gps==1
matrix mean2 = e(mean), J(1,1,`n1')
matrix sd2 = e(sd), J(1,1,.)

foreach item in mean1 mean2 sd1 sd2 {
	estadd matrix `item'
}

esttab using "$output/desc_stat.tex", style(tex) booktabs unstack ///
label nonumber cells("mean1(fmt(a2)) sd1(fmt(a2)) mean2(fmt(a2)) sd2(fmt(a2))") ///
collabels("Mean" "S.D." "Mean" "S.D.") ///
nogaps noobs nostar nonotes replace 

filefilter "$output/desc_stat.tex" "$output/desc_stat_edit.tex", from("c1") to("Observations") replace

exit 
